using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
using UnityEngine;

public class Level
{
	[XmlAttribute("id")]
	public int Id{ get; set; }
	
	[XmlAttribute("allowPrimary")]
	public bool AllowPrimary{ get; set; }
	
	[XmlAttribute("allowSecondary")]
	public bool AllowSecondary{ get; set; }
	
	[XmlElement("name")]
	public string Name{ get; set; }
	
	[XmlElement("maxFilter")]
	public int MaxFilter{ get; set; }
	
	[XmlElement("maxMirror")]
	public int MaxMirror{ get; set; }
	
	[XmlElement("maxMixer")]
	public int MaxMixer{ get; set; }
	
	[XmlElement("maxDivider")]
	public int MaxDivider{ get; set; }
	
	[XmlElement("object")]
    public List<GPObject> GamePlayObjects{ get; set; }
	
	public Level(){
		AllowPrimary = true;
		AllowSecondary = true;
		GamePlayObjects = new List<GPObject>();
	}
	
	public Level(GameObject go, string name){
		AllowPrimary = LevelConstants.allowPrimary;
		AllowSecondary = LevelConstants.allowSecondary;
		GamePlayObjects = new List<GPObject>();
		
		Id = 0;
		Name = name;
		
		MaxFilter = LevelConstants.maxFilter;
		MaxMirror = LevelConstants.maxMirror;
		MaxMixer = LevelConstants.maxMixer;
		MaxDivider = LevelConstants.maxDivider;
		
		foreach(Transform child in go.transform){
			GPObject gpo = new GPObject(child.gameObject);
			
			GamePlayObjects.Add(gpo);
		}
	}
	
	public override string ToString ()
	{
		return string.Format ("[Level: Id={0}, Name={1}, GamePlayObjects={2}]", Id, Name, GamePlayObjects);
	}
	
}

